package com.project.pet.controller.wx;

import com.project.pet.common.ResponseData;
import com.project.pet.pojo.Star;
import com.project.pet.pojo.WxUser;
import com.project.pet.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController("wxUserController")
@RequestMapping("/api/wx/user")
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("/isLogin")
    public String isLogin(){
        return "ok";
    }

    @PostMapping("/login")
    public ResponseData<Object> wxLogin(@RequestBody WxUser wxUser, @RequestParam String code){
        return userService.wxLogin(code,wxUser);
    }

    @GetMapping("/findById")
    public ResponseData<Object> findById(){
        return userService.findById();
    }

    @PostMapping("/update")
    public ResponseData<Object> updateByPrimaryKey(@RequestBody WxUser wxUser){
        return userService.updateByPrimaryKey(wxUser);
    }

    @GetMapping("/selectAll")
    public ResponseData<Object> selectAll(){
        return userService.selectAll();
    }
    @GetMapping("/wxUserIfRegister/{code}")
    public ResponseData<Object> wxLogin(@PathVariable String code){
        return userService.wxUserIfRegister(code);
    }
}
